﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Messaging;
using log4net;
namespace Guoc.DAL.AOPFilter
{
   
   public class LogFilter :AopFilter
    {
       public LogFilter(IMessageSink next) : base(next) { }


       public override void OnExecuted(IMessage msg)
       {
           IMethodReturnMessage returnMsg = (IMethodReturnMessage)msg;
           IMethodMessage method = (IMethodMessage)msg;           
           ILog logTool = LogManager.GetLogger(method.TypeName);
           if (returnMsg.Exception == null)
           {
               logTool.Fatal("NHibernate.SQL日志:" + method.MethodName); 
           }
           else
           {
               logTool.Error("NHibernate.SQL日志:" + method.MethodName, returnMsg.Exception);
           }
       }
    }
}
